<template>
  <div>
    <div class="gva-form-box">
      <el-form :model="formData" ref="elFormRef" label-position="right" :rules="rule" label-width="80px">
        <el-form-item label="影片ID:" prop="movieId">
          <el-input v-model.number="formData.movieId" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt&wx | 剧目ID:" prop="albumId">
          <el-input v-model.number="formData.albumId" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="影片名:" prop="title">
          <el-input v-model="formData.title" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="总集数:" prop="seqNum">
          <el-input v-model.number="formData.seqNum" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="竖版封面内容md5:" prop="coverList">
          <el-input v-model="formData.coverList" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt | 必 | 发行年份:" prop="year">
          <el-input v-model.number="formData.year" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt |必 | 短剧更新状态 - 1：未上映 - 2：更新中 - 3：已完结:" prop="albumStatus">
          <el-input v-model.number="formData.albumStatus" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="（tt必） | 短剧推荐语（tt-12）:" prop="recommendation">
          <el-input v-model="formData.recommendation" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="必 | 短剧简介（200 汉字以内）:" prop="desp">
          <el-input v-model="formData.desp" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt | 必 | 短剧类目标签（1-3 个）:" prop="tagList">
          <el-input v-model="formData.tagList" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt |非 | 资质状态- 1：未报审 该字段可先忽略，统一传入1即可。备案信息关注record_audit_info传入即可:" prop="qualification">
          <el-input v-model.number="formData.qualification" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt | 必 | 平均单集时长，单位分钟:" prop="duration">
          <el-input v-model.number="formData.duration" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="首必|剧目制作方:" prop="productionOrganisation">
          <el-input v-model="formData.productionOrganisation" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt | 必 | 导演 |:" prop="director">
          <el-input v-model="formData.director" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt | 必| 制作人:" prop="producer">
          <el-input v-model="formData.producer" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="必| 演员:" prop="actor">
          <el-input v-model="formData.actor" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt | 必| 内容梗概（1000 汉字以内）:" prop="summary">
          <el-input v-model="formData.summary" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt&wx | 必| md5-成本配置比例情况:" prop="costDistributionUri">
          <el-input v-model="formData.costDistributionUri" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt | 选 | md5-承诺书:" prop="assuranceUri">
          <el-input v-model="formData.assuranceUri" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt | 必 | 制作成本类型- 10：30万以下 -| 20：30～100万 -| 30：100万以上:" prop="playletProductionCost">
          <el-input v-model.number="formData.playletProductionCost" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt | 选 | 编剧:" prop="screenWriter">
          <el-input v-model="formData.screenWriter" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt| 选 |  备案号类型, 普通备案号（tt:10）,重点备案号(tt:20):" prop="recordType">
          <el-input v-model.number="formData.recordType" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt| 选 |  广电备案号:" prop="broadcastRecordNumber">
          <el-input v-model="formData.broadcastRecordNumber" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt| 必 | 授权 |  被授权小程序（上限500）:" prop="appIdList">
          <el-input v-model="formData.appIdList" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="tt| 非 |  页面绑定， 0未绑定 1绑定成功:" prop="schemaBindStatus">
          <el-input v-model.number="formData.schemaBindStatus" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="版本号:" prop="version">
          <el-input v-model.number="formData.version" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="送审状态 | 状态- 1：未提交- 2：已提交- 3：已审出:" prop="status">
          <el-input v-model.number="formData.status" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="auditStatus字段:" prop="auditStatus">
          <el-input v-model.number="formData.auditStatus" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="审核备注:" prop="auditMsg">
          <el-input v-model="formData.auditMsg" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="短剧版本上下线状态  0或者不填:上线   1：指定版本下线  2 默认未上线:" prop="playletStatus">
          <el-input v-model.number="formData.playletStatus" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="创建人:" prop="createUid">
          <el-input v-model.number="formData.createUid" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="创建时间:" prop="createTime">
          <el-date-picker v-model="formData.createTime" type="date" placeholder="选择日期" :clearable="true"></el-date-picker>
       </el-form-item>
        <el-form-item label="更新人:" prop="updateUid">
          <el-input v-model.number="formData.updateUid" :clearable="true" placeholder="请输入" />
       </el-form-item>
        <el-form-item label="更新时间:" prop="updateTime">
          <el-date-picker v-model="formData.updateTime" type="date" placeholder="选择日期" :clearable="true"></el-date-picker>
       </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="save">保存</el-button>
          <el-button type="primary" @click="back">返回</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script setup>
import {
  createMoviesAuditTt,
  updateMoviesAuditTt,
  findMoviesAuditTt
} from '@/api/moviesAuditTt'

defineOptions({
    name: 'MoviesAuditTtForm'
})

// 自动获取字典
import { getDictFunc } from '@/utils/format'
import { useRoute, useRouter } from "vue-router"
import { ElMessage } from 'element-plus'
import { ref, reactive } from 'vue'

const route = useRoute()
const router = useRouter()

const type = ref('')
const formData = ref({
            movieId: 0,
            albumId: 0,
            title: '',
            seqNum: 0,
            coverList: '',
            year: 0,
            albumStatus: 0,
            recommendation: '',
            desp: '',
            tagList: '',
            qualification: 0,
            duration: 0,
            productionOrganisation: '',
            director: '',
            producer: '',
            actor: '',
            summary: '',
            costDistributionUri: '',
            assuranceUri: '',
            playletProductionCost: 0,
            screenWriter: '',
            recordType: 0,
            broadcastRecordNumber: '',
            appIdList: '',
            schemaBindStatus: 0,
            version: 0,
            status: 0,
            auditStatus: 0,
            auditMsg: '',
            playletStatus: 0,
            createUid: 0,
            createTime: new Date(),
            updateUid: 0,
            updateTime: new Date(),
        })
// 验证规则
const rule = reactive({
})

const elFormRef = ref()

// 初始化方法
const init = async () => {
 // 建议通过url传参获取目标数据ID 调用 find方法进行查询数据操作 从而决定本页面是create还是update 以下为id作为url参数示例
    if (route.query.id) {
      const res = await findMoviesAuditTt({ ID: route.query.id })
      if (res.code === 0) {
        formData.value = res.data.removiesAuditTt
        type.value = 'update'
      }
    } else {
      type.value = 'create'
    }
}

init()
// 保存按钮
const save = async() => {
      elFormRef.value?.validate( async (valid) => {
         if (!valid) return
            let res
           switch (type.value) {
             case 'create':
               res = await createMoviesAuditTt(formData.value)
               break
             case 'update':
               res = await updateMoviesAuditTt(formData.value)
               break
             default:
               res = await createMoviesAuditTt(formData.value)
               break
           }
           if (res.code === 0) {
             ElMessage({
               type: 'success',
               message: '创建/更改成功'
             })
           }
       })
}

// 返回按钮
const back = () => {
    router.go(-1)
}

</script>

<style>
</style>
